local wdtx_dismantlementSkill = fk.CreateSkill {
  name = "wdtx__dismantlement_skill",
}



wdtx_dismantlementSkill:addEffect("cardskill", {
  prompt = "#wdtx__dismantlement_skill",
  target_num = 1,
  on_use = function(self, room, cardUseEvent)
    local mark = cardUseEvent.card:getMark("@up_dismant")
    if room.logic.class.name == "wdtx_logic" and mark > 0 then
      cardUseEvent.disresponsiveList = room.alive_players
    end
  end,
  mod_target_filter = function(self, player, to_select, selected, card)
    return to_select ~= player and not to_select:isAllNude()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local from = effect.from
    local to = effect.to
    if effect.from.dead or effect.to.dead or effect.to:isAllNude() then return end
    local cid
    if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@up_dismant") > 0 then
      local extra_add = effect.card:getMark("@up_dismant") + 1
      cid = room:askToChooseCards(from,{
        max = math.min(extra_add,#to:getCardIds("hej")),
        min = math.min(1,#to:getCardIds("hej")),
        flag = "hej",
        skill_name = wdtx_dismantlementSkill.name,
        target = to,
      })
    else
      cid = room:askToChooseCard(from,{
        flag = "hej",
        skill_name = wdtx_dismantlementSkill.name,
        target = to,
      })
    end
    room:throwCard(cid, wdtx_dismantlementSkill.name, to, from)
  end
})


return wdtx_dismantlementSkill